package com.spring.config;

import org.springframework.core.io.Resource;
import org.springframework.core.type.AnnotationMetadata;
import org.springframework.core.type.ClassMetadata;
import org.springframework.core.type.classreading.MetadataReader;
import org.springframework.core.type.classreading.MetadataReaderFactory;
import org.springframework.core.type.filter.TypeFilter;

import java.io.IOException;
import java.util.Set;

/**
 * Description:
 *
 * @author lijie
 * @create 2019-01-15 0:30
 * Update by lijie 2019-01-15 0:30
 */
public class MyTypeFilter implements TypeFilter {
    @Override
    public boolean match(MetadataReader metadataReader, MetadataReaderFactory metadataReaderFactory) throws IOException {
        //获取该类的所有注解
        AnnotationMetadata annotationMetadata = metadataReader.getAnnotationMetadata();
        Set<String> annotationTypes = annotationMetadata.getAnnotationTypes();
        for(String annotationType:annotationTypes){
            System.out.println("注解类型:" + annotationType);
        }
        //获取该类的类信息
        ClassMetadata classMetadata = metadataReader.getClassMetadata();
        //获取该类的资源路径
        Resource resource = metadataReader.getResource();
        return false;
    }
}
